package cn.aopmin.listener;

import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 *
 * @author 白豆五
 * @since 2025/4/6
 */
@Component
public class AListener {

    @Async("customThreadPool")
    @EventListener
    public void onApplicationEvent(DemoEvent event) {
        // if (event.getType() == 1){
        try {
            Thread.sleep(2000);
            System.out.println("A收到事件：" + event.getMessage() + "----" + LocalDateTime.now());
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        // }
    }
}